package com.weijianhuawen.wjblog.admin.convert;

import com.weijianhuawen.wjblog.admin.mode.vo.user.*;
import com.weijianhuawen.wjblog.common.domain.dos.UserDetailDo;
import com.weijianhuawen.wjblog.common.domain.qo.UserDetailQo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-12-11 0:38
 */

@Mapper
public interface UserConvert {
    // 创建转换器实体
    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);
    // 将vo转换为do
    UserDetailDo updateVo2Do(UpdateUserDetailInformationReqVo bean);
    // 将do转换为 vo
    @Mappings({
            @Mapping(target = "registerTime", expression = "java(bean.getCreateTime())"),
            @Mapping(target = "updateDataTime", expression = "java(bean.getUpdateTime())"),
            @Mapping(target = "userId", expression = "java(String.valueOf(bean.getUserId()))")
    })
    FindUserDetailInformationRspVo Do2findVo(UserDetailDo bean);

    UserDetailDo updatePersonVo2Do(UpdateUserPersonInformationReqVo bean);

    // 将vo转换为qo
    UserDetailQo pageVo2Qo(FindUserDetailPageListReqVo bean);

    // 将do转换为分页vo
    @Mappings({
            @Mapping(target = "userId", expression = "java(String.valueOf(bean.getUserId()))"),
            @Mapping(target = "id", expression = "java(String.valueOf(bean.getId()))"),
            @Mapping(target = "isCancel", expression = "java(bean.getIsDeleted())")
    })
    FindUserDetailPageListRspVo do2pageVo(UserDetailDo bean);
    // 将用户资料vo转换为do
    UserDetailDo messageVo2DetailDo(UpdateUserMessageReqVo vo);
}
